package cc.example;

import reactor.core.publisher.Flux;
import reactor.core.publisher.FluxSink;

public class 创建序列create {

    public static void main(String[] args) throws InterruptedException {




        Flux<Object> flux = Flux.create(objectFluxSink -> {
            MyEventListener listener = new MyEventListener(objectFluxSink);
            for (int i = 0; i < 10; i++) {
              listener.online("张" + i);
            }
        });

        flux.log().subscribe();

    }



    public static class MyEventListener {
        private FluxSink<Object> sink;

        public MyEventListener(FluxSink<Object> sink) {
            this.sink = sink;
        }

        public void online(String username) {
            System.out.println("用户登录了: " + username);
            sink.next(username);

        }
    }

}


